﻿using Microsoft.AspNetCore.Mvc.Filters;

namespace SmartProduction.Write.API.Filters
{
    /// <summary>
    /// 全局异常过虑器
    /// </summary>
    public class MyExceptionFilter : IExceptionFilter
    {
        private readonly ILogger<MyExceptionFilter> logger;

        public MyExceptionFilter(ILogger<MyExceptionFilter> logger)
        {
            this.logger = logger;
        }

        void IExceptionFilter.OnException(ExceptionContext context)
        {
            logger.LogInformation("全局异常" + context.Exception.Message);
            context.ExceptionHandled = true;
        }

    }
}